package com.leadingsoft.pwxk.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leadingsoft.pwxk.model.SyncRecord;
import com.leadingsoft.pwxk.repository.SyncRecordRepository;
import com.leadingsoft.pwxk.services.SyncRecordService;

/**
 * 
 * @author ysh
 * @desc 同步记录类
 */
@Service
public class SyncRecordServiceImpl implements SyncRecordService {

	@Autowired
	SyncRecordRepository syncRecordRepository;

	@Override
	public void save(SyncRecord s) {
		syncRecordRepository.save(s);
	}

	@Override
	public SyncRecord findLatestRecord(String interfaceName) {
		List<SyncRecord> all = syncRecordRepository.findByInterfaceNameOrderBySyncRecordTimeDesc(interfaceName);
		if (null != all && all.size() > 0) {
			return all.get(0);
		}
		return null;
	}

	@Override
	public void update(SyncRecord s) {
		syncRecordRepository.saveAndFlush(s);
	}

}
